#include <chrono>
#include <iostream>
using HRT = std::chrono::high_resolution_clock;
using SYST = std::chrono::system_clock;
using STDT = std::chrono::steady_clock;

std::string ltime(time_t* t)
{
    char buf[64]{};
    std::tm lt;
    localtime_r(t, &lt);
    strftime(buf, sizeof(buf) - 1, "%Y-%m-%d %H:%M:%S", &lt);
    return buf;
}

template <class C, class D>
std::ostream& operator<<(std::ostream& os,
                         const std::chrono::time_point<C, D>& tp)
{
    char buf[64]{};
    auto t = SYST::to_time_t(tp);
    return os << ltime(&t);
}

using namespace std;
int main(int argc, char** argv)
{
    auto ht = HRT::now();
    auto syst = SYST::now();
    auto stdt = STDT::now();
    cout << ht << '\n';
    cout << syst << '\n';
    // cout << stdt << '\n'; // steady_clock doesn't support conversion to
    // system_clock::to_time_t
    return 0;
}
